let Yard = document.querySelector("#yard");
let Livingroom = document.querySelector("#livingroom");
let Bedroom = document.querySelector("#bedroom");

let ya1 = "/Yard"; //地址拼接
let living = "/Livingroom"; //地址拼接
let bed = "/Bedroom"; //地址拼接
let admit_statue = "/Get-admitstatue"; //地址拼接


setInterval(function() {
    let sendRequest2 = new XMLHttpRequest();
    sendRequest2.open("GET", admit_statue, true);
    sendRequest2.send(null);
    sendRequest2.onreadystatechange = function () {
      if (sendRequest2.readyState === 4 && sendRequest2.status === 200) {
        let str = sendRequest2.responseText;
        if (str == "false") window.location.href = "./disadmit.html";
      }
    };

  }, 200); // 间隔时间为2000毫秒（2秒）

document.addEventListener("DOMContentLoaded", () => {
    let sendRequest2 = new XMLHttpRequest();
    sendRequest2.open("GET", admit_statue, true);
    sendRequest2.send(null);
    sendRequest2.onreadystatechange = function () {
      if (sendRequest2.readyState === 4 && sendRequest2.status === 200) {
        let str = sendRequest2.responseText;
        if (str == "false") window.location.href = "./disadmit.html";
      }
    };
});

Yard.addEventListener("click", () => {
  console.log("YAARD1");
  let sendRequest = new XMLHttpRequest();
  sendRequest.open("POST", ya1, true);
  sendRequest.send(null);
  sendRequest.onreadystatechange = function () {
    if (sendRequest.readyState === 4 && sendRequest.status === 200) {
      console.log(sendRequest.responseText);
    }
  };
});

Livingroom.addEventListener("click", () => {
  let sendRequest = new XMLHttpRequest();
  sendRequest.open("POST", living, true);
  sendRequest.send(null);
  sendRequest.onreadystatechange = function () {
    if (sendRequest.readyState === 4 && sendRequest.status === 200) {
      console.log(sendRequest.responseText);
    }
  };
});

Bedroom.addEventListener("click", () => {
  let sendRequest = new XMLHttpRequest();
  sendRequest.open("POST", bed, true);
  sendRequest.send(null);
  sendRequest.onreadystatechange = function () {
    if (sendRequest.readyState === 4 && sendRequest.status === 200) {
      console.log(sendRequest.responseText);
    }
  };
});

function shrinkImage(img) {
  img.classList.add("small"); // 添加 'small' 类，使图片缩小
}

function restoreImage(img) {
  img.classList.remove("small"); // 移除 'small' 类，使图片恢复原始大小
}
